﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ongoal.Quotation.Sqlsugar
{
    public interface IDbFactory
    {
        /// <summary>
        /// 获取数据库实例
        /// </summary>
        /// <param name="name">数据库连接名称 单一数据库连接可为空</param>
        /// <returns></returns>
        SqlSugarClient GetDbContext(string name = "", bool IsFilterRule = true);
        /// <summary>
        /// 获取数据库实例
        /// </summary>
        /// <param name="onErrorEvent">执行错误回调</param>
        /// <param name="name">数据库连接名称 单一数据库连接可为空</param>
        /// <returns></returns>
        SqlSugarClient GetDbContext(Action<Exception> onErrorEvent, string name = "", bool IsFilterRule = true);
        /// <summary>
        /// 获取数据库实例
        /// </summary>
        /// <param name="onExecutedEvent">执行后回调方法</param>
        /// <param name="name">数据库连接名称 单一数据库连接可为空</param>
        /// <returns></returns>
        SqlSugarClient GetDbContext(Action<string, SugarParameter[]> onExecutedEvent, string name = "", bool IsFilterRule = true);
        /// <summary>
        /// 获取数据库实例
        /// </summary>
        /// <param name="onExecutingChangeSqlEvent">SQL执行前 可以修改SQL 回调方法</param>
        /// <param name="name">数据库连接名称 单一数据库连接可为空</param>
        /// <returns></returns>
        SqlSugarClient GetDbContext(Func<string, SugarParameter[], KeyValuePair<string, SugarParameter[]>> onExecutingChangeSqlEvent, string name = "", bool IsFilterRule = true);
        /// <summary>
        /// 获取数据库实例
        /// </summary>
        /// <param name="onExecutedEvent"></param>
        /// <param name="onExecutingChangeSqlEvent"></param>
        /// <param name="onErrorEvent"></param>
        /// <param name="name">数据库连接名称 单一数据库连接可为空</param>
        /// <returns></returns>
        SqlSugarClient GetDbContext(Action<string, SugarParameter[]> onExecutedEvent = null, Func<string, SugarParameter[], KeyValuePair<string, SugarParameter[]>> onExecutingChangeSqlEvent = null, Action<Exception> onErrorEvent = null, string name = "", bool IsFilterRule = true);
        /// <summary>
        /// 获取数据库实例
        /// </summary>
        /// <param name="OnLogExecuting">SQL执行前事件</param>
        /// <param name="onExecutedEvent">执行后回调方法</param>
        /// <param name="onExecutingChangeSqlEvent">SQL执行前 可以修改SQL 回调方法</param>
        /// <param name="onErrorEvent">执行错误回调</param>
        /// <param name="OnDiffLogEvent">数据库操作前和操作后的数据变化 例如OnDiffLogEvent = it =>{ var editBeforeData = it.BeforeData;var editAfterData = it.AfterData;var sql = it.Sql;var parameter = it.Parameters;var data = it.BusinessData; var time = it.Time; var diffType = it.DiffType;//枚举值 insert 、update 和 delete 用来作业务区分 };</param>
        /// <param name="name">数据库连接名称 单一数据库连接可为空</param>
        /// <returns></returns>
        SqlSugarClient GetDbContext(Action<string, SugarParameter[]> OnLogExecuting = null, Action<string, SugarParameter[]> onExecutedEvent = null, Func<string, SugarParameter[], KeyValuePair<string, SugarParameter[]>> onExecutingChangeSqlEvent = null, Action<Exception> onErrorEvent = null, Action<DiffLogModel> OnDiffLogEvent = null, string name = "", bool IsFilterRule = true);
        //
        // 摘要:
        //     获取数据库实例
        //
        // 参数:
        //   name:
        //     数据库连接名称 单一数据库连接可为空
        SqlSugarScope GetDbScope(string name = "");

        //
        // 摘要:
        //     获取数据库实例
        //
        // 参数:
        //   name:
        //     数据库连接名称 单一数据库连接可为空
        SqlSugarScope GetDbScope(string name = "", bool IsFilterRule = true);

        //
        // 摘要:
        //     获取数据库实例
        //
        // 参数:
        //   onErrorEvent:
        //     执行错误回调
        //
        //   name:
        //     数据库连接名称 单一数据库连接可为空
        SqlSugarScope GetDbScope(Action<Exception> onErrorEvent, string name = "", bool IsFilterRule = true);

        //
        // 摘要:
        //     获取数据库实例
        //
        // 参数:
        //   onExecutedEvent:
        //     执行后回调方法
        //
        //   name:
        //     数据库连接名称 单一数据库连接可为空
        SqlSugarScope GetDbScope(Action<string, SugarParameter[]> onExecutedEvent, string name = "", bool IsFilterRule = true);

        //
        // 摘要:
        //     获取数据库实例
        //
        // 参数:
        //   onExecutingChangeSqlEvent:
        //     SQL执行前 可以修改SQL 回调方法
        //
        //   name:
        //     数据库连接名称 单一数据库连接可为空
        SqlSugarScope GetDbScope(Func<string, SugarParameter[], KeyValuePair<string, SugarParameter[]>> onExecutingChangeSqlEvent, string name = "", bool IsFilterRule = true);

        //
        // 摘要:
        //     获取数据库实例
        //
        // 参数:
        //   onExecutedEvent:
        //
        //   onExecutingChangeSqlEvent:
        //
        //   onErrorEvent:
        //
        //   name:
        //     数据库连接名称 单一数据库连接可为空
        SqlSugarScope GetDbScope(Action<string, SugarParameter[]> onExecutedEvent = null, Func<string, SugarParameter[], KeyValuePair<string, SugarParameter[]>> onExecutingChangeSqlEvent = null, Action<Exception> onErrorEvent = null, string name = "", bool IsFilterRule = true);

        //
        // 摘要:
        //     获取数据库实例
        //
        // 参数:
        //   OnLogExecuting:
        //     SQL执行前事件
        //
        //   onExecutedEvent:
        //     执行后回调方法
        //
        //   onExecutingChangeSqlEvent:
        //     SQL执行前 可以修改SQL 回调方法
        //
        //   onErrorEvent:
        //     执行错误回调
        //
        //   OnDiffLogEvent:
        //     数据库操作前和操作后的数据变化 例如OnDiffLogEvent = it =>{ var editBeforeData = it.BeforeData;var
        //     editAfterData = it.AfterData;var sql = it.Sql;var parameter = it.Parameters;var
        //     data = it.BusinessData; var time = it.Time; var diffType = it.DiffType;//枚举值
        //     insert 、update 和 delete 用来作业务区分 };
        //
        //   name:
        //     数据库连接名称 单一数据库连接可为空
        SqlSugarScope GetDbScope(Action<string, SugarParameter[]> OnLogExecuting = null, Action<string, SugarParameter[]> onExecutedEvent = null, Func<string, SugarParameter[], KeyValuePair<string, SugarParameter[]>> onExecutingChangeSqlEvent = null, Action<Exception> onErrorEvent = null, Action<DiffLogModel> OnDiffLogEvent = null, string name = "", bool IsFilterRule = true);
    }
}
